home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
-
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 16 April 2001
- //
- // Procedure Name:
- // art3dPaintCheckDefautBrush
- //
- // Description:
- // Makes sure that the nodes that store the default paint effects brushes
- // for paint, blur, and smear have been created.
- //
- // Input Arguments:
- // $mode - mode to make sure default brush exists for ("Paint", "Smear",
- // or "Blur")
- //
- // Return Value:
- // None.
- //
- global proc art3dPaintCheckDefaultBrush( string $mode ) {
- string $defaultBrushName;
- string $defaultBrushScript;
-
- // Nodes which store the saved brush settings
- //
- global string $gArt3dPaintLastPaintBrush = "art3dPaintLastPaintBrush";
- global string $gArt3dPaintLastBlurBrush = "art3dPaintLastBlurBrush";
- global string $gArt3dPaintLastSmearBrush = "art3dPaintLastSmearBrush";
-
- // These are the names of the brushes that we will use as defaults
- //
- string $defaultPaintBrush = "airbrush/defaultPaint";
- string $defaultSmearBrush = "airbrush/defaultSmear";
- string $defaultBlurBrush = "airbrush/defaultBlur";
-
- // Names that the default brush had when the saved settings were in place
- // (e.g. fire1)
- //
- global string $gArt3dPaintLastPaintBrushName;
- global string $gArt3dPaintLastBlurBrushName;
- global string $gArt3dPaintLastSmearBrushName;
-
- // Check if the default brushes exist
- //
- int $defaultPaintExists, $defaultSmearExists, $defaultBlurExists;
-
- switch ( $mode ) {
- case "Paint":
- $defaultBrushName = $gArt3dPaintLastPaintBrush;
- $defaultBrushScript = $defaultPaintBrush;
- $gArt3dPaintLastPaintBrushName = basename( $defaultBrushScript, "" );
- break;
- case "Smear":
- $defaultBrushName = $gArt3dPaintLastSmearBrush;
- $defaultBrushScript = $defaultSmearBrush;
- $gArt3dPaintLastSmearBrushName = basename( $defaultBrushScript, "" );
- break;
- case "Blur":
- $defaultBrushName = $gArt3dPaintLastBlurBrush;
- $defaultBrushScript = $defaultBlurBrush;
- $gArt3dPaintLastBlurBrushName = basename( $defaultBrushScript, "" );
- break;
- default:
- error "unsupported mode in art3dPaintCheckDefaultBrush";
- }
-
- if ( `objExists $defaultBrushName` ) {
- // The brush node already exists;
- return;
- }
-
- // Figure out where the brushes live
- //
- string $brushDir = getenv( "MAYA_LOCATION" ) + "/brushes/";
-
- // Make a copy of the existing selection
- //
- string $currSelection[] = `ls -sl`;
-
- // Make a copy of the current brush so that we can put it back
- //
- string $defaultName = getDefaultBrush();
- string $copyReasults[] = `duplicate $defaultName`;
- string $defaultCopy = $copyReasults[0];
-
- // Create the node where we will store the brush settings in the future
- //
- createNode "brush" -n $defaultBrushName;
- int $ok = false;
-
- string $brushBaseName = basename( $defaultBrushScript, "" ) + ".mel";
- if ( `exists $brushBaseName` ) {
- // The paint brush is in our script path. Use that instead. This
- // will allow users to override the default brush by putting a
- // brush script in their own script directory
- //
- if ( !catch( eval( "source " + $brushBaseName ) ) ) {
- $ok = true;
- }
- }
- if ( !$ok ) {
- // Need to pick up the brush out of the brushes directory
- //
- if ( !catch( eval( "source \"" + $brushDir + $defaultBrushScript + ".mel\"" ) ) ) {
- $ok = true;
- }
- }
-
- if ( !$ok ) {
- error ( "Failed to load default paint effects paint brush: " + $defaultBrushScript );
- }
-
- // Store the brush settings for the default brush we just loaded into our
- // save node
- //
- copyNode( getDefaultBrush(), $defaultBrushName );
-
- // Put back the old default brush
- //
- brushPresetSetup();
- copyNode( $defaultCopy, getDefaultBrush() );
- rename( getDefaultBrush(), $defaultName );
- delete $defaultCopy;
-
- // Set the paint effects brush mode.
- //
- string $currContext = `currentCtx`;
- art3dPaintCtx -e -brushtype "effectsBrush" $currContext;
- art3dPaintEffectsBrushCallback( "art3dPaintCtx" );
-
- // Replece the old selection list so that we don't modify Maya's state
- //
- select -r $currSelection;
- }
-